// js document


$(function() {

    $(document).bind("contextmenu", function(e) {
        return false;
    });

    var $window = $(window);
    var $ww = $window.width();
    // $window.height()
    var $wh = $window.height() + 20;
    var i = false;

    var $banner = $('.header');
    $banner.height($wh - 150);

    if ($ww < 768) {
        //400
        $banner.height(420);
        i = false;
        $('.nav-top-l').hide();
    } else {
        $('.nav-top-l').show();
        $banner.height($wh - 150);
    }

    $(window).resize(function() {
        var $window = $(window);
        var $ww = $window.width();

        if ($ww < 768) {
            i = false;
            $('.nav-top-l').hide();
            //400
            $banner.height(420);
        } else {
            $('.nav-top-l').show();

            $banner.height($wh - 150);
        }
    })


    $('.menu_nav').click(function() {
        if (i = !i) {
            $('.nav-top-l').slideDown();
        } else {
            $('.nav-top-l').slideUp();
        }

    })


    scroll(function(x) {
        var scorolltop = $(document).scrollTop();
        if (scorolltop == 0) {
            $('.navbar').removeClass('fixed');
            //$('.logo img').attr('src','images/logo.png');

        }

        if (x == "down") {
            $('.navbar').addClass('fixed');
            //$('.logo img').attr('src','images/logo2.png');
        }
    })

    $('.to_top').click(function() {
        $('html, body').animate({ scrollTop: 0 }, 400);
    })

    $(".case_list_body ul li").hover(function() {
        $(this).addClass("hover")
        $(this).find(".caselogo").stop(true, true).animate({ "top": "0" }, 400);
        $(this).find(".bgs_01").stop(true, true).animate({ "bottom": "0" }, 400);
    }, function() {
        $(this).removeClass("hover")
        $(this).find(".caselogo").stop(true, true).animate({ "top": "-243" }, 400);
        $(this).find(".bgs_01").stop(true, true).animate({ "bottom": "-60" }, 400);
    })

    $(".case_list2 ul li").hover(function() {
        $(this).find(".goto").stop(true, true).animate({ "margin-top": "-35%", "opacity": "1" }, { duration: 600, easing: "easeOutBounce" });
    }, function() {
        $(this).find(".goto").stop(true, true).animate({ "margin-top": "-200%", "opacity": "0" }, { duration: 400 });
    })



});


function scroll(fn) {
    var beforeScrollTop = document.body.scrollTop,
        fn = fn || function() {};
    window.addEventListener("scroll", function() {
        var afterScrollTop = document.body.scrollTop,
            delta = afterScrollTop - beforeScrollTop;
        if (delta === 0) return false;
        fn(delta > 0 ? "down" : "up");
        beforeScrollTop = afterScrollTop;
    }, false);
}